import coin.exchange.base.kr_rest.native_public_client_base as npubcb
import coin.exchange.coincheck.kr_rest.constants as exchange_constants


class CoincheckNativePublicClient(npubcb.NativePublicClientBase):
  def __init__(self):
    npubcb.NativePublicClientBase.__init__(self, url="https://coincheck.com")

  def get_ticker(self, pair):
    return self._get_as_json("/api/ticker", params=dict(pair=pair))

  def get_public_trades(self, pair):
    self._get_as_json("/api/trades", params=dict(pair=pair))

  def get_orderbook(self, pair):
    return self._get_as_json("/api/order_book", params=dict(pair=pair))

  def get_calc_rate(self, order_type, pair, amount, price):
    self._get_as_json("/api/exchange/orders/rate",
                      params=dict(order_type=order_type, pair=pair, amount=amount, price=price))

  def get_buy_rate(self, pair):
    self._get_as_json("/api/rate/%s" % pair, dict(pair=pair))

  def queryAll(self):
    for symbol in exchange_constants.coin_list:
      print(self.get_orderbook(symbol))


if __name__ == "__main__":
  client = CoincheckNativePublicClient()
  client.queryAll()
